package com.ac.untitlede.controller;


import com.ac.untitlede.entity.EduTeacher;
import com.ac.untitlede.service.IEduTeacherService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 讲师 前端控制器
 * </p>
 *
 * @author untitlede
 * @since 2021-07-06
 */
@Slf4j
@RestController
@RequestMapping("/edu-teacher")
public class EduTeacherController {
    private IEduTeacherService ide;

    @Autowired
    public void setIde(IEduTeacherService ide) {
        this.ide = ide;
    }

    @PostMapping("/selectAll")
    @ApiOperation(value = "查询所用教师")
    public String teacherAll(){
        List<EduTeacher> list = ide.list();
        log.warn(""+list);

        return ""+list;
    }
    @PostMapping("/selectById")
    @ApiOperation(value = "查询单个教师")
    public EduTeacher teacherById(String eid){
        EduTeacher edu=ide.getById(eid);
        log.warn(""+edu);
        return edu;
    }
    @PostMapping("/deleteById")
    @ApiOperation(value = "删除单个教师")
    public String teacherDeleteById( String eid){
        boolean edu=ide.removeById(eid);
        log.warn(""+edu);
        return edu?"删除成功":"删除失败";
    }

    @PostMapping("/insertTeacher")
    @ApiOperation(value = "添加教师")
    public String teacherDeleteById(EduTeacher edu){
        boolean save = ide.save(edu);
        log.warn(""+edu);
        return save?"添加成功":"添加失败";
    }
}

